package com.shiyi.strategy.imp;

import com.shiyi.strategy.FileUploadStrategy;
import com.shiyi.strategy.imp.minio.MinioUtilS;
import io.minio.GetPresignedObjectUrlArgs;
import io.minio.http.Method;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Service("minioUploadImpl")
@RequiredArgsConstructor
public class MinioUploadImpl implements FileUploadStrategy {

    @Autowired
    private MinioUtilS minioUtilS;

    @Override
    public String fileUpload(MultipartFile file, String suffix) {
        List<String> upload = minioUtilS.upload(new MultipartFile[]{file});
        return minioUtilS.fileUrl(upload.get(0),false);
    }

    @Override
    public Boolean deleteFile(String... fileName) {
        return null;
    }
}
